interface StatusBarHeight {
  statusBarHeight: number
}
export const useStatusBarHeight = (): StatusBarHeight => {
  const statusBarHeight = ref<number>(20)
  const calculateHeight = (): void => {
    try {
      const systemInfo = uni.getSystemInfoSync()
      statusBarHeight.value = Number(systemInfo.statusBarHeight) || 20
    } catch (error) {
      statusBarHeight.value = 20 // 降级处理
    }
  }
  onMounted(() => {
    calculateHeight()
    // 监听屏幕旋转变化（如需）
    uni.onWindowResize(calculateHeight)
  })
  onUnmounted(() => {
    // 移除监听（内存优化）
    uni.offWindowResize(calculateHeight)
  })
  return { statusBarHeight: statusBarHeight.value }
}
